package juc.atomic;

import java.util.concurrent.atomic.*;

/**
 * 原子类 java.util.concurrent.atomic
 * 实现方式: CAS + volatile
 * <p>
 * 原子更新基本类型
 * * {@link AtomicInteger}
 * * {@link AtomicLong}
 * * {@link AtomicBoolean}
 * 原子更新数组
 * * {@link AtomicIntegerArray}
 * * {@link AtomicLongArray}
 * * {@link AtomicReferenceArray}
 * 原子更新引用类型
 * * {@link AtomicReference}
 * * {@link AtomicStampedReference}
 * * {@link AtomicMarkableReference}
 * 原子更新字段类
 * * {@link AtomicIntegerFieldUpdater}
 * * {@link AtomicLongFieldUpdater}
 * * {@link AtomicReferenceFieldUpdater}
 * jdk8 新增 (与AtomicLong相比,LongAdder更多地用于收集统计数据,而不是细粒度的同步控制)
 * * {@link DoubleAccumulator}
 * * {@link DoubleAdder}
 * * {@link LongAccumulator}
 * * {@link LongAdder}
 *
 * @author 王霄
 * @date 2021/9/19 22:31
 */
public class AtomicDemo {

    public static final AtomicInteger count = new AtomicInteger(0);

    public static void main(String[] args) {
        int i = count.compareAndExchange(1, 10);
        System.out.println(i);
        System.out.println(count);
    }
}
